package basic_practice_1015;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
/**
 * @author MemoryC
 * */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
		String skewString="";
		while((skewString=buffer.readLine())!=null) {
			char[] skew=skewString.toCharArray();
            int len=skew.length;
            
            int num=0;
            
            int pow=2;
            for(int i=len-1;i>=0;i--) {
            	int bit=skew[i]-'0';
            	num+=bit*(pow-1);
            	pow*=2;
            }
            System.out.println(num);
		}
		         
      
    }
}



class Main2 {

	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);
		         
        while(scanner.hasNext()) {
            char[] skew=scanner.next().toCharArray();
            int len=skew.length;
            
            int num=0;
            
            int pow=2;
            for(int i=len-1;i>=0;i--) {
            	int bit=skew[i]-'0';
            	num+=bit*(pow-1);
            	pow*=2;
            }
            System.out.println(num);
        }
        scanner.close();
    }
}